<template>
<div class="page">
  <div class="user-info">门店：021040 &nbsp;&nbsp;&nbsp; 企微：123214124112</div>
  <div class="page-title">默认欢迎<br>语设置</div>
  <div 
    v-for="item,index in welcomeList" 
    :key="index" 
    :class="['box',item.extType==0?'one-box':'',item.checked?'select-box':'']">
    <div v-if="item.extType==0">
      <div class="title-box">
        <RJCheck @radioChange="select($event,index)" :defaultChecked="item.checked"/>
        <div class="content content-box">欢迎语文本<span>（可编辑）</span></div>
      </div>
      <el-input
        class="textarea"
        type="textarea"
        :rows="8"
        placeholder="请输入"
        v-model="item.textContent">
      </el-input>
    </div>
    <div class="content-box" v-if="item.extType==3">
      <RJCheck @radioChange="select($event,index)" :defaultChecked="item.checked"/>
      <div class="content content-box">{{item.miniTitle}}<span>（根据门店实际情况选择）</span></div>
    </div>
  </div>
  <div class="btn-box">
    <div class="confirm-btn" @click="confirm">提交欢迎语</div>
    <div class="refresh-btn">刷新</div>
  </div>
</div>
</template>
<script>
import RJCheck from '@/components/RJCheck.vue'

export default {
  data() {
    return {
      selectList: [0,1,2],
      welcomeText: '',
      welcomeList: []
    }
  },
  components: {
    RJCheck
  },
  created() {
    this.getWelcomeList()
  },
  methods: {
    select(bool,type) {
      this.welcomeList[type].checked = bool
    },
    //获取欢迎语初始配置
    getWelcomeList() {
      let res = [
        {
            "id": 1,
            "extType": 0,
            "miniTitle": null,
            "textContent": "测试一下-等您很久啦~"
        },
        {
            "id": 2,
            "extType": 3,
            "miniTitle": "首旅如家小程序",
            "textContent": null
        },
        {
            "id": 3,
            "extType": 3,
            "miniTitle": "随行管家小程序",
            "textContent": null
        }
      ]
      res.forEach((item,index) => {
        if(index == 2) {
          item.checked = true
        }else {
          item.checked = false
        }
        
      })
      this.welcomeList = res
      console.log(this.welcomeList)
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .el-textarea__inner{
  padding: 10px 15px;
}
.page{
  .user-info{
    padding: 15px 18px;
    font-size: 14px;
    font-family: MicrosoftYaHei;
    background: #F6F6F6;
    font-weight: bold;
    color: #1B1F26;
  }
  .page-title{
    font-size: 14px;
    font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
    font-weight: bold;
    color: #1B1F26;
    line-height: 19px;
    padding: 15px 0 6px 18px;
  }
  .box{
    display: flex;
    padding: 17px 31px 17px 18px;
    .content{
      margin-left: 8px;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      color: #1B1F26;
      line-height: 19px;
      span{
        color: #999999;
      }
    }
    .content-box{
      display: flex;
    }
  }
  .select-box{
    background: #F6F6F6;
  }
  .one-box{
    display: block;
    .title-box{
      display: flex;
    }
    .textarea{
      margin: 14px 0 0 26px;
      width: 90%;
    }
  }
  .btn-box{
    display: flex;
  }
  .confirm-btn,.refresh-btn{
    width: 107px;
    height: 30px;
    background: #3D7FFF;
    border-radius: 2px;
    font-size: 12px;
    font-family: MicrosoftYaHei;
    color: #FFFFFF;
    line-height: 30px;
    text-align: center;
    margin: 16px 0 0 44px;
  }
  .refresh-btn{
    margin-left: 20px;
  }
}
</style>